<?php

namespace Biz\Requests\Site;

use Biz\Dictionaries\TitleDict;
use Illuminate\Validation\Rule;
use Biz\Dictionaries\CountryDict;
use Biz\Constants\ApplicationConstants;
use Lumen\Validation\Rules\AttributeInRule;
use Lumen\Validation\Validators\RequestValidator;
use Biz\Dictionaries\Paper\PresentationPreferenceDict;

/**
 * SitePaperRequest.
 *
 * @license [http://www.85do.com] [杭州永奥网络科技有限公司]
 * @copyright Copyright (c) 2018-2026 Hangzhou Yongao Technology Co., Ltd. All rights reserved.
 */
class SitePaperRequest extends RequestValidator
{
    /**
     * Get custom rules for validator errors.
     *
     * @return array
     */
    public function rules(): array
    {
        return [
            'number'                              => 'required|string|max:128',
            'theme_id'                              => 'required|string|max:255',
            'presentation_preference'             => [
                'required',
                'string',
                Rule::in(PresentationPreferenceDict::keys()),
            ],
            'abstract'                             => 'required',
            'abstract.file_url'                    => 'required|string|max:255',
            'translations'                         => 'required',
            'translations.*'                       => [
                'required',
                new AttributeInRule(ApplicationConstants::$Languages),
            ],
            'translations.*.title'               => 'required|max:255',
            'translations.*.remark'              => 'max:255',
            'authors'                            => 'required',
            'authors.*.email'                    => 'required|distinct|email|max:255',
            'authors.*.title'                    => [
                'required',
                'string',
                'max:8',
                Rule::in(TitleDict::keys()),
            ],
            'authors.*.first_name'               => 'required|max:32',
            'authors.*.middle_name'              => 'max:32',
            'authors.*.last_name'                => 'required|max:32',
            'authors.*.country'                  => [
                'required',
                'string',
                'max:12',
                Rule::in(CountryDict::keys()),
            ],
            'authors.*.presenting_author'                => 'required|boolean',
            'authors.*.corresponding_author'                => 'required|boolean',
        ];
    }
}
